//
//  DefaultUril.m
//  SHISEIDO_Consultation
//
//  Created by jon due on 11/10/06.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "DefaultUril.h"

@implementation DefaultUril

//usertDefaultsの初期化
+(void)initUserDefaults{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    
    if(![ defaults objectForKey:key_userName]){
        [defaults setObject:@"----" forKey:key_userName];
    }
    if(![ defaults objectForKey:key_AlermTime]){
        [ defaults setObject:[ NSDate date ] forKey:key_AlermTime ];
    }
    if(![ defaults objectForKey:key_isAlert]){
        [ defaults setInteger:0 forKey:key_isAlert ];
    }
    if(![ defaults objectForKey:key_isScreen]){
        [ defaults setInteger:0 forKey:key_isScreen ];
    }
}

//usertDefaultsへのかきこみ
+(void)writeDefaultsInteger:(NSString*)key:(int)value{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    
    [ defaults setInteger:value forKey:key ];
    [ defaults synchronize ];
    
    if ( ![defaults synchronize] ) {
        NSLog( @"failed ..." );
    }
}

//usertDefaultsへの読み込み
+(int)readDefaultsInteger:(NSString*)key{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    int value = [ defaults integerForKey:key];  // KEY_Bの内容をBOOL型として取得
    return value;
}

//stringDefaultsへのかきこみ
+(void)writeDefaultsString:(NSString*)key:(NSString*)value{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    
    [ defaults setObject:value forKey:key ];
    [ defaults synchronize ];
    
    if ( ![defaults synchronize] ) {
        NSLog( @"failed ..." );
    }
}

//stringDefaultsへの読み込み
+(NSString*)readDefaultsString:(NSString*)key{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults ];
    NSString* value = [ defaults stringForKey:key];
    return value;
}

//stringDefaultsへの書き込み
+(void)writeDefaultsDate:(NSString*)key:(NSDate*)value{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    
    [ defaults setObject:value forKey:key ];
    [ defaults synchronize ];
    
    if ( ![defaults synchronize] ) {
        NSLog( @"failed ..." );
    }
}

//stringDefaultsへの読み込み
+(NSDate*)readDefaultsDate:(NSString*)key{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults ];
    NSDate* value = [ defaults objectForKey: key];
    return value;

}




@end
